package ninja.awesome.game.gameobject;

import ninja.awesome.framework.Graphics;
import ninja.awesome.framework.Image;
import ninja.awesome.game.MainGameScreen;
import ninja.awesome.game.MainGameScreen.PlayingMode;
import ninja.awesome.game.classes.Neutral;
import ninja.awesome.game.compat.Rectangle;
import ninja.awesome.game.main.Controller;
import ninja.awesome.game.main.Physics;
import ninja.awesome.game.main.Sprites;

public class Life extends GameObj implements Neutral {

	private Image image;
	private int speed = 1;
	MainGameScreen game;
	Sprites s;
	Controller c;

	public Life(int x, int y, int speed, MainGameScreen game, Controller c, Sprites s) {
		super(x, y);
		this.speed = speed;
		this.game = game;
		this.c = c;
		this.s = s;
		image = s.getLife();

	}

	@Override
	public void update() {
		yLoc += speed;
		if (game.getPlayingMode() == PlayingMode.SINGLE) {
			if (Physics.collision(this, game.getNinja())) {
				game.getNinja().setLives(game.getNinja().getLives() + 1);
				c.removeNeutral(this);
			}

		} else if (game.getPlayingMode() == PlayingMode.MULTIPLE) {
			if (Physics.collision(this, game.getNinja())) {
				game.getNinja().setLives(game.getNinja().getLives() + 1);
				c.removeNeutral(this);
			}

			if (Physics.collision(this, game.getNinja2())) {
				game.getNinja2().setLives(game.getNinja2().getLives() + 1);
				c.removeNeutral(this);
			}

		}

	}

	@Override
	public void draw(Graphics g) {
		g.drawImage(image, xLoc, yLoc);

	}

	@Override
	public Rectangle getBounds() {
		return new Rectangle(xLoc, yLoc, 16, 16);
	}

	@Override
	public int getX() {
		return xLoc;
	}

	@Override
	public int getY() {
		return yLoc;
	}

}
